package io.bdmc.modules.bss.controller;

import java.time.LocalDateTime;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import io.bdmc.common.annotation.SysLog;
import io.bdmc.common.utils.R;
import io.bdmc.common.utils.RedisUtils;
import io.bdmc.modules.bss.entity.BarSetting;
import io.bdmc.modules.bss.service.BarSettingService;
import io.bdmc.modules.sys.controller.AbstractController;


/**
 * <p>
 * 设置表 前端控制器
 * </p>
 *
 * @author HuangLu
 * @since 2019-01-08
 */
@RestController
@RequestMapping("/bss/setting")
public class BarSettingController extends AbstractController{

    @Autowired
	private BarSettingService settingSvs;
	
	@Autowired
	private RedisUtils redisUtils;

	@RequestMapping("/info")
	//@RequiresPermissions("sys:dev:list")
	public R info(Integer id){
		//查询列表数据
		if(id<=0){
			return R.error("参数错误");
		}
        BarSetting setting = settingSvs.getById(id);
		return R.ok().putData(setting);
    }
    

     /**
	 * 修改设备
	 */
	@SysLog("修改设备")
	@RequestMapping("/update")
	@RequiresPermissions("bss:setting:update")
	public R update(@RequestBody BarSetting setting){
		setting.setUpdateTime(LocalDateTime.now());
		settingSvs.updateById(setting);
		redisUtils.set("setting", setting);
		return R.ok();
    }
}

